<?php
class b2c_mdl_goods_tip extends dbeav_model{
	
	
     public function modifier_dt_ids($row){
		$dlytype=app::get('b2c')->model('dlytype')->getList('dt_id,dt_name',array('filter_sql'=>'dt_id in('.$row.')'),0,-1,'ordernum ASC');
		$dt_names=array();
		foreach($dlytype as $line){
			$dt_names[]=$line['dt_name'];
		}
		$row=implode(' , ',$dt_names);
        return $row;
     }
	 
     public function modifier_payment_app_ids($row){
		 if(!empty($row)){
			 $payments=app::get('ectools')->model('payment_cfgs');
			 $row_arr=strstr($row,',')?explode(',',$row):array($row);
			 $app_name_str='';
			 $i=1;
			 foreach($row_arr as $app_id){
				 $app_name=$payments->getList('app_id,app_name',array('app_id'=>$app_id));
				 if($i>1){
					$app_name_str.=' , '.$app_name[0]['app_name'];
				 }else{
					 $app_name_str=$app_name[0]['app_name'];
				 }
				 $i++;
			 }
			 return $app_name_str;
		 }else{
			 return $row;
		 }
     }
	 
	 	
	function pre_recycle($data){
		$tip_ids=array();
		foreach($data as $tip_item){
			$tip_ids[]=$tip_item['tip_id'];
		}
		$tip_ids_str=implode(',',$tip_ids);
		$mdl_goods = app::get('b2c')->model('goods');
		if($mdl_goods->getList('goods_id',array('filter_sql'=>'tip_id in ('.$tip_ids_str.')'))){
			$this->recycle_msg = app::get('b2c')->_('所选择的仓库中有商品,不能删除');
			return false;
		}		
		return true;
	}
	
}
